@extends('develop.layoutEdit')

@section('title')
    <li class="cur">
        <span>卡券设置</span>
    </li>
@endsection


@section('css')
    <style>
        .layer-go-back{
            display:none;
        }
    </style>
@endsection

@section('content')

    <div class="form-group">
        <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否限制门店：</label>
        <div class="col-sm-9" >
            <div class="layui-form">
                <input type="radio" name="code_api_limit_mall"  value="1" title="是" @if( !isset($configure['code_api_limit_mall']) || $configure['code_api_limit_mall'] == 1 ) checked @endif>
                <input type="radio" name="code_api_limit_mall"  value="0" title="否" @if( isset($configure['code_api_limit_mall']) && $configure['code_api_limit_mall'] == 0 ) checked @endif>
                <span style="margin-left: 10px; color:#737373;">（注：券接口设置，只适用于券接口）</span>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否限制提货时间：</label>
        <div class="col-sm-9" >
            <div class="layui-form">
                <input type="radio" name="code_api_limit_time"  value="1" title="是" @if( !isset($configure['code_api_limit_time']) || $configure['code_api_limit_time'] == 1 ) checked @endif>
                <input type="radio" name="code_api_limit_time"  value="0" title="否" @if( isset($configure['code_api_limit_time']) && $configure['code_api_limit_time'] == 0 ) checked @endif>
                <span style="margin-left: 10px; color:#737373;">（注：券接口设置，只适用于券接口）</span>
            </div>
        </div>
    </div>

    <div class="form-group" >
        <label  class="col-sm-3 control-label">pos过机订单类型：</label>
        <div class="col-sm-7 ">
            <div class="layui-form">
                <input type="checkbox"  name="pos_bill_type"  value="1" title="送货上门" @if( !isset($configure['pos_bill_type']) || $configure['pos_bill_type'] == 1 || $configure['pos_bill_type'] == 3 ) checked @endif>&nbsp;
                <input type="checkbox"  name="pos_bill_type"  value="2" title="门店自提" @if( $configure['pos_bill_type'] == 2 || $configure['pos_bill_type'] == 3 )checked @endif>&nbsp;
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否同步第三方erp：</label>
        <div class="col-sm-9" >
            <div class="layui-form">
                <input type="radio" name="is_sync_third_erp"  value="1" title="是" @if( isset($configure['is_sync_third_erp']) && $configure['is_sync_third_erp'] == 1 ) checked @endif>
                <input type="radio" name="is_sync_third_erp"  value="0" title="否" @if( !isset($configure['is_sync_third_erp']) || $configure['is_sync_third_erp'] == 0 ) checked @endif>
                <span style="margin-left: 10px; color:#737373;">（注：是.有spur模式，否.无spur模式）</span>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"><span class="red pr5">*</span>是否同步微信卡包：</label>
        <div class="col-sm-9">
            <div class="layui-form">
                <input type="radio" name="is_sync_wechat"  value="1" title="是" @if( isset($configure['is_sync_wechat']) && $configure['is_sync_wechat'] == 1 ) checked @endif>
                <input type="radio" name="is_sync_wechat"  value="0" title="否" @if( !isset($configure['is_sync_wechat']) || $configure['is_sync_wechat'] == 0 ) checked @endif>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"></label>
        <div class="col-sm-9">
            <input type="hidden" name="function_id" id="function_id" value="{{ $function_id or ''}}">
            <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success" >
        </div>
    </div>

@endsection

@section('js')
    <script>

    layui.use(['form'], function(){
        var form = layui.form();
    });
    var func = {

        //保存
        edit:function(){

            var message_log = '' ;
            var configure = E.getFormValues('edit-form') ;

            //参数判断
            if( E.isEmpty( configure.function_id ) || !E.isInt( configure.function_id ) ) {
                message_log += '参数错误<br/>' ;
            }

            if( message_log ) {
                layer.alert( message_log , { icon:2 });
                return false ;
            }

            if ( (configure.pos_bill_type).length == 2 ) {
                configure.pos_bill_type =  3;
            } else if ( (configure.pos_bill_type).length == 1){
                configure.pos_bill_type =  configure.pos_bill_type[0];
            } else if ( (configure.pos_bill_type).length == 0 ) {
                configure.pos_bill_type = 0;
            }

            layer.confirm("您确认保存该设置吗？",{icon:3,offset:'50px'}, function ( index ){
                layer.close( index );
                E.ajax( {
                    type:'get',
                    url: '/lar/develop/function/store/'+function_id,
                    data: configure,
                    dataType:'json',
                    // 返回值判断
                    success: function ( obj ){

                        if ( obj.code == 200 ) {
                            layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                        } else {
                            layer.alert( obj.message , { icon: 2 } ) ;
                        }
                    }
                } ) ;
            });
        }

    };

    </script>
@endsection